package com.wei.miaosha.redis;

public abstract class BasePrefix implements KeyPrefix {

    private int expireSeconds;//过期时间

    private String prefix;

    public BasePrefix(String prefix) {//0代表永不过期
        this(0, prefix);
    }

    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }

    /**
     * 过期时间,默认永不过期
     */
    public int expireSeconds() {//默认0代表永不过期
        return expireSeconds;
    }

    public String getPrefix() {
        //类名
        String className = getClass().getSimpleName();
        return className + ":" + prefix;
    }

}
